package newnes.io.memory;
/**
 * @(#)PrgRom.java
 *
 *A representation of Read-only memory.
 * @author DG
 * @version 1.00 2009/3/28
 */
import newnes.io.memory.Memory;
import java.nio.ByteBuffer;

public class Rom extends Memory {
	
	public Rom(int size){
		super(size);
	}
	
	/**
	 *Load data into this rom.
	 */
	public void loadData(byte[] b){
		ByteBuffer memory_buffer = getMemoryBuffer();
		memory_buffer.put(b,0,b.length);
	}
	
	public int writeToMemory(int address, byte value){
		return -1;
	}
	
	public int readFromMemory(int address){
		ByteBuffer memory_buffer = getMemoryBuffer();
		int buffer_location = address-getAddressSpace().getStartAddress();
		buffer_location = buffer_location & getAddressMask();
		return memory_buffer.get(buffer_location);	
	}
}
